Skip to content

33292 replace AspectMock from BaseGenerateCommandTest #840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

SilinMykola
Copy link

Description

Eliminate AspectMock usage from dev/tests/unit/Magento/FunctionalTestFramework/Console/BaseGenerateCommandTest.php

Fixed Issues (if relevant)

  1. [MFTF] Replace AspectMock with PHPUnit for BaseGenerateCommandTest magento2#33292: [MFTF] Replace AspectMock with PHPUnit for BaseGenerateCommandTest #33292

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/verification tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)
  • Changes to Framework doesn't have backward incompatible changes for tests or have related Pull Request with fixes to tests

@jilu1
Copy link
Contributor

jilu1 commented Jun 28, 2021

@jilu1
Copy link
Contributor

jilu1 commented Jun 28, 2021

@SilinMykola
Thank you for your pull request! We will review and update you soon.

@jilu1
Copy link
Contributor

jilu1 commented Jun 28, 2021

Comment on lines 179 to 185
$testObjectHandler = TestObjectHandler::getInstance();
$reflection = new \ReflectionClass(TestObjectHandler::class);
$reflectionMethod = $reflection->getMethod('initTestData');
$reflectionMethod->setAccessible(true);
$output = $reflectionMethod->invoke($testObjectHandler);
$this->assertEquals('', $output);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code does not seem to be necessary since we are not stubbing initTestData?

This is not a usual way for unit tests, but it does work for eliminating the usage of AspectMock with no framework refactoring. We can use this solution.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jilu1 Hello! I removed this code.

Comment on lines 191 to 197
$suiteObjectHandler = SuiteObjectHandler::getInstance();
$reflection = new \ReflectionClass(SuiteObjectHandler::class);
$reflectionMethod = $reflection->getMethod('initSuiteData');
$reflectionMethod->setAccessible(true);
$output = $reflectionMethod->invoke($suiteObjectHandler);
$this->assertEquals('', $output);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, is this code necessary since we are not stubbing initSuiteData?

Comment on lines 18 to 22
public function tearDown(): void
{
AspectMock::clean();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a precaution, can we set tests and suites to [] forTestObjectHandler and SuiteObjectHandler in tearDown()?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jilu1 I changed tearDown method and set [] for TestObjectHandler and SuiteObjectHandler

@sivaschenko
Copy link
Member

@SilinMykola thanks for the pull request! Would you be able to respond to the code review comments?

@SilinMykola
Copy link
Author

@sivaschenko yes, I'll try to change code after review. I need some time for this.

@bohdan-harniuk bohdan-harniuk self-requested a review July 19, 2021 09:53
@bohdan-harniuk
Copy link
Contributor

Hello, @jilu1

I have a little bit helped for @SilinMykola with the aspect mock replacement here to match the original behaviour (+ with the implementation of what you asked for). Please, proceed with the code review.

cc: @SilinMykola, @sivaschenko

@bohdan-harniuk bohdan-harniuk removed their request for review July 19, 2021 12:34
Copy link
Contributor

@andrewbess andrewbess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @SilinMykola @bohdan-harniuk
Now changes look well for me.
Thank you for your contribution.
Hello @jilu1 could you please recheck
Thank you in advance.

@andrewbess andrewbess requested a review from jilu1 July 20, 2021 16:13
@jilu1
Copy link
Contributor

jilu1 commented Jul 21, 2021

@magento-engcom-team
Copy link

@jilu1 the pull request successfully imported.

@bohdan-harniuk bohdan-harniuk added Partner: Atwix partners-contribution Pull Request is created by Magento Partner labels Jul 21, 2021
@jilu1
Copy link
Contributor

jilu1 commented Jul 21, 2021

@bohdan-harniuk
Great solution! Looks good to me. Thanks for your contribution!

@bohdan-harniuk bohdan-harniuk self-requested a review July 21, 2021 14:55
@andrewbess andrewbess self-assigned this Jul 22, 2021
@bohdan-harniuk
Copy link
Contributor

Hello, @jilu1

This task was finished without creating new singletons, so it is not a blocker. We can go further here.

Thanks, Bohdan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accept Partner: Atwix partners-contribution Pull Request is created by Magento Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants